package com.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.bean.Role;
import com.bean.RolePermission;
import com.mapper.RoleMapper;
import com.mapper.RolePermissionMapper;
import com.service.RoleService;

/**
 * @author author : 张鹏
 * @date createTime：2018年3月19日 上午10:10:31
 * @Description: 该类的功能描述
 */
@Service
public class RoleServiceImpl implements RoleService {
	@Resource
	private RoleMapper roleMapper;

	@Resource
	private RolePermissionMapper rolePermissionMapper;

	@Override
	public List<Role> getAllRole() {
		// TODO Auto-generated method stub
		return roleMapper.selectAll();
	}

	@Override
	public List<RolePermission> getPermissionByRoleId(int roleId) {
		return rolePermissionMapper.selectByRoleId(roleId);
	}
	
	@Override
	public int  deletePermissionByRoleId(int roleId) {
		return rolePermissionMapper.deleteByRoleId(roleId);
	}
	
	@Override
	public int  createPermissionByRoleId(RolePermission rolePermission) {
		return rolePermissionMapper.insert(rolePermission);
	}
	

	@Override
	public int createNewRole(Role role) {
		// TODO Auto-generated method stub
		return roleMapper.insert(role);
	}

	@Override
	public int updateRole(Role role) {
		// TODO Auto-generated method stub
		return roleMapper.updateByPrimaryKey(role);
	}

	@Override
	public int deleteRoleByRoleId(int roleId) {
		// TODO Auto-generated method stub
		return roleMapper.deleteByPrimaryKey(roleId);
	}

}
